from django import forms
from django.contrib.auth.models import User
from .models import *
from captcha.fields import CaptchaField


class RegistrationForm(forms.ModelForm):
    passwd = forms.CharField(label="Password", widget=forms.PasswordInput)
    passwd2 = forms.CharField(label="Conform Password", widget=forms.PasswordInput)
    captcha = CaptchaField()

    class Meta:
        model = User
        fields = ("username", "email")

    def clean_passwd2(self):
        cd = self.cleaned_data
        if cd["passwd"] != cd["passwd2"]:
            raise forms.ValidationError("passwords do not match.")
        return cd["passwd2"]


# class UserProfileForm(forms.ModelForm):
#     class Meta:
#         model = UserProfile
#         fields = ('birth', 'phone', 'address', 'aboutme')


# class TestForm(forms.Form):
#     ch01 = (
#             (1, 'first'),
#             (2, 'second'),
#             )
#     f01 = forms.ChoiceField(choices=ch01)
#     f02 = forms.CharField(max_length=111)
#     f03 = forms.DateTimeField()
#     captcha = CaptchaField()


class CaptchaForm(forms.Form):
    captcha = CaptchaField()
